package com.joysuch.wwyt.bp.repository;

import com.joysuch.wwyt.bp.entity.investigate.BpSafeTableItem;
import com.joysuch.wwyt.bp.enums.SafeTableSourceTypes;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @Author ZhangDong
 * @Date 2020/12/2 14:26
 */
public interface BpSafeTableItemDao extends JpaRepository<BpSafeTableItem, Long> {

    @Query("select id from BpSafeTableItem t where t.safeTableId=:safeTableId")
    List<Long> findIdBySafeTableId(Long safeTableId);

    @Query("update BpSafeTableItem t set t.deleteFlag ='1' where t.id in (:idList)")
    @Modifying
    void deleteAllByIdIn(List<Long> idList);

    List<BpSafeTableItem> findBySourceAndSourceId(SafeTableSourceTypes source, Long sourceId);

    List<BpSafeTableItem> findBySourceAndSourceIdIn(SafeTableSourceTypes source, List<Long> sourceIds);
}
